
const express = require('express') ;

const {port} = require('./config/config');

const body = require('body-parser') ;

// 
const router = require('./router');   // 引入router文件夹下面的index.js这个文件   简写了省略了index.js
const { errHandler } = require('./middleware/errHandler');

const app = express() ;

// 配置前端路由
app.use('/static' , express.static('./client/')) ;    

app.use(body({extended:false})) ;
app.use(body.json()) ;

// 配置接口文件
app.use('/api' , router)

app.use(errHandler) ;

app.listen(port , () => console.log('启动中...')) ;